﻿using SqlSugar;

namespace My.Web.Model;
[SugarTable("AICFlowStatistics_T_MenuMeta", TableDescription = "元数据")]
public class MenuMeta
{
   
  //  public string? MenuMetaId { get;   set; }//用long 导致前端精度丢失
    [SugarColumn(IsPrimaryKey = true)]
    public string? MenuId { get;   set; }
   

    public string? Icon { get;   set; }
    /// <summary>
    /// 外链地址,根据选项来启用
    /// </summary>
    public string? ExternalLink { get;   set; }
    public int IsAffix { get;   set; }
    public int IsHide { get;   set; }
    public int IsIframe { get;   set; }
    public int IsKeepAlive { get;   set; }
    /// <summary>
    /// 权限标识;菜单所属角色
    /// </summary>
    public string? Roles { get;  set; }

    public static MenuMeta Create(Menu metas)
    {
                                //服务器时间修改一定也要修改WorkId
        if (metas.menuMeta is null) throw new ArgumentNullException("menu");
        MenuMeta meta = new();
     
        string id = SnowFlakeSingle.Instance.NextId().ToString();
     
       // meta.MenuMetaId = id;
        meta.MenuId = metas.MenuId;
        meta.Icon = metas.menuMeta.Icon;
        meta.ExternalLink = metas.menuMeta.ExternalLink;
        meta.IsAffix = metas.menuMeta.IsAffix;
        meta.IsHide = metas.menuMeta.IsHide;
        meta.IsIframe = metas.menuMeta.IsIframe;
        meta.IsKeepAlive = metas.menuMeta.IsKeepAlive;
     
        meta.Roles = metas.menuMeta.Roles;
        return meta;
    }
    public static MenuMeta Update(Menu metas)
    {
        //服务器时间修改一定也要修改WorkId
        if (metas.menuMeta is null) throw new ArgumentNullException("menu");
        MenuMeta meta = new();
        meta.MenuId = metas.MenuId;
        meta.Icon = metas.menuMeta.Icon;
        meta.ExternalLink = metas.menuMeta.ExternalLink;
        meta.IsAffix = metas.menuMeta.IsAffix;
        meta.IsHide = metas.menuMeta.IsHide;
        meta.IsIframe = metas.menuMeta.IsIframe;
        meta.IsKeepAlive = metas.menuMeta.IsKeepAlive;
        meta.Roles = metas.menuMeta.Roles;
        return meta;
    }
}
